<!-- 列表显示头 开始 -->
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="STYLE1" bgcolor="b5d6e6">
  <tr>
    <td colspan="3" align="left" background='<%=$urr+"skin/images/bg.gif"%>'><img src='<%=$urr+"skin/icon/list.gif"%>' width="16" height="16" />
      <span class="STYLE3"><%=@titles %></span></td>
  </tr>
</table>
<!-- 列表显示头 结束 -->
<!-- 列表查询项 开始 -->
<table width="100%" border="0" cellpadding="2" cellspacing="2" class="STYLE1">
  <% form_for :resource, :url => { :action => "list" } do |f| %>
    <tr>
      <td height="30" align="left">
        <%= f.label "资源名称" %>
        <%= f.text_field :name%>
        <%= f.label "所属频道" %>
        <%= select_tag("section[channel_id]",
          options_for_select(Channel.find(:all).collect{|i| [ i.name,i.id]}.insert(0,['全部频道',nil]),
            @section.channel_id))-%>
        <%= f.label "栏目名称" %>
        <%= select_tag("col[id]",
          options_for_select(Section.find(:all).collect{|i| [ i.name,i.id]}.insert(0,['请选择栏目',nil]),
            @col.id))-%>
        <%= f.submit '搜索' %>
      </td>
    </tr>
  <% end %>
</table>
<!-- 列表查询项 结束 -->
<!-- 列表操作项 开始 -->
<table width="100%" border="0" cellpadding="2" cellspacing="2" class="STYLE1">
  <tr>
    <td align="right" width="100%">
      &nbsp;
    </td>
    <td align="right">
      <%= button_to "增加资源", :controller => "resources",:action => "new" %>
    </td>
    <td align="right">
      <%= button_to "扫描导入静态资源", {:controller => "resources",:action => "scan_upload",:is_dy => 0},:confirm => "点击导入资源按钮后记得关闭当前浏览器?", :method => :new %>
      <%= button_to "扫描导入动态资源", {:controller => "resources",:action => "scan_upload",:is_dy => 1},:confirm => "点击导入资源按钮后记得关闭当前浏览器?", :method => :new %>
    </td>
  </tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6"  class="STYLE1">
  <tr>
    <td width="3%" height="22" align="center" bgcolor="#33FFFF">请选择</td>
    <td width="15%" height="22" align="center" bgcolor="#33FFFF">资源名称</td>
    <td  height="22" align="center" bgcolor="#33FFFF">顺序</td>
    <td height="22" align="center" bgcolor="#33FFFF">状态</td>
    <td height="22" align="center" bgcolor="#33FFFF">动态</td>
    <td align="center" bgcolor="#33FFFF">所属频道</td>
    <td height="22" align="center" bgcolor="#33FFFF">所属栏目</td>
    <td height="22" align="center" bgcolor="#33FFFF">资源类型</td>
    <td height="22" align="center" bgcolor="#33FFFF">资源标签</td>
    <td height="22" align="center" bgcolor="#33FFFF">资源路径</td>
    <td align="center" bgcolor="#33FFFF" class="STYLE1">操作</td>
  </tr>

  <% @resources.each_with_index do |resource,index| %>
    <%
    bg_col = "#CCFFCC"
    unless index%2 == 0
      bg_col = "#FFCCCC"
    end
  %>
    <tr>
      <td align="center" bgcolor=<%= bg_col %> valign='middle'>
        <%= check_box_tag  'resource_'+ resource.id.to_s ,'yes',false %>
      </td>
      <td align="center" bgcolor=<%= bg_col %>>
        <% img =  get_img(resource)%>
        <% unless img.nil? %>
          <%=image_tag(get_img(resource), :size => "30x30", :alt => "",:border=>0)%>
        <%end%>
        <%= link_to resource.name,  :controller => "resources", :action => "edit", :id => resource.id,:page => @page  %>
      </td>
      <td width="3%" align="center" bgcolor=<%= bg_col %>><%=h resource.orders %></td>
      <td width="3%" align="center" bgcolor=<%= bg_col %>><%=h resource.status %></td>
      <td width="3%" align="center" bgcolor=<%= bg_col %>>
        <%  if resource.is_dy %>
          <%= "动态" %>
        <%  else %>
          <%= "静态" %>
        <% end %>
      </td>
      <td width="12%" align="center" bgcolor=<%= bg_col %>><%=h resource.section.channel.name %></td>
      <td width="12%" align="center" bgcolor=<%= bg_col %>><%=h resource.section.name %></td>
      <td width="3%" align="center" bgcolor=<%= bg_col %>>
        <%  if resource.res_type == "1" %>
          <%= "图集" %>
        <%  elsif resource.res_type == "2" %>
          <%= "图文" %>
        <%  else %>
          <%= "小说" %>
        <% end %>
      </td>
      <td width="19%" align="center" bgcolor=<%= bg_col %>>
        <% get_tags(resource).each do|tag|%>
          <%=h Tag.find(tag.tag_id).name %> <%=h "|" %>
        <% end %>
      </td>
      <td align="center" bgcolor=<%= bg_col %>><%=h resource.res_dir %></td>
      <td align="center" bgcolor=<%= bg_col %>>
        <%= link_to '查看',  :controller => "resources", :action => "show", :id => resource.id %>
        <%= link_to '编辑',  :controller => "resources", :action => "edit", :id => resource.id  %>
        <%= link_to '删除',  :controller => "resources", :action => "delete", :id => resource.id, :page => @page  %>
    </tr>
  <% end %>
  <tr bgcolor="#DDDD00">
    <td align="left" colspan="2">
      &nbsp;&nbsp;
      <input id="all" type="checkbox" onclick="doall('resource',this.checked,9);"/>     
      <%=h "全选"%>
      <%= destroy_selected('destroy_selected','resource_id[]',9 ,[:resources, :destroy_selected],form_authenticity_token) %>
    </td>
    <td align="left" colspan="5">
      <%=h "目标栏目："%>
      <%= select_tag("section_tag",
        options_for_select(Section.find(:all).collect{|i| [ i.name,i.id]}.insert(0,['请选择栏目',nil]),
          @section.id))-%>
      <%= move_selected('move_selected','section_tag','resource_id[]',9 ,[:resources, :move_selected],form_authenticity_token) %>
      <%= copy_selected('copy_selected','section_tag','resource_id[]',9 ,[:resources, :copy_selected],form_authenticity_token) %>
    </td>
    <td align="left" colspan="3">
      <%=h "标签："%>
      <input id="tag_input" name="tag_name" type="text" value = ""/>
      <%= add_tag_selected('add_tag_selected','tag_input','resource_id[]',9 ,[:resources, :add_tag_selected],form_authenticity_token) %>
    </td>
    <td align="left">
      <%= to_channel('to_channel','resource_id[]',9 ,[:resources, :to_channel],form_authenticity_token) %>
      <%= move_channel('move_channel','resource_id[]',9 ,[:resources, :move_channel],form_authenticity_token) %>
    </td>
  </tr>
</table>

<!-- 列表分页项 开始 -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr align="center">
    <td align="center" height="40">      
      <%= will_paginate @resources, :params => {:res_name => @res_name,:channel_id => @channel_id,:col_id => @col.id}, :style => 'font-size: small'%>
    </td>
  </tr>
</table>
<!-- 列表分页项 结束 -->